function e = forney(Xinv,X,kk,Om,Lam,numErr)

    Xk_inv = Xinv(kk);
        
    Xk = X(kk);

    %Calc formal derivative: remove even powers, replace with odd powers
    %shifted down
    if mod(length(Lam),2) == 0
        odds = Lam(2:2:length(Lam));
    else
        odds = [Lam(2:2:length(Lam)) -1];
    end
    Lam(1:2:length(Lam)) = odds;
    Lam(2:2:length(Lam)) = -1*ones(1,length(2:2:length(Lam)));
    Lambda_prime = polyPlugIn(Lam,Xk_inv);
    
    % Evaluate Omega(Xk_inv)
    Om_Xk_inv = polyPlugIn(Om,Xk_inv);

    % Compute e_ik
    numerator = elementMult(Xk,Om_Xk_inv);
    % numerator = Om_Xk_inv;
    e = elementDiv(numerator,Lambda_prime);

end
